//package com.example.springbootdemo.aop;
//
//import com.example.springbootdemo.annotation.DelRedisCache;
//import com.example.springbootdemo.util.CommonUtil;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Method;
//
///**
// * 根据key前缀模糊删除满足条件的缓存数据
// */
//
//@Aspect
//@Component
//public class DelRedisCacheAspect {
//
//    @Autowired
//    private RedisUtil redisUtil;
//
//    @Pointcut("@annotation(com.hzyl.admin.annotation.DelRedisCache)")
//    public void annotationPointCut() {
//    }
//
//    @Before("annotationPointCut()")
//    public void before(JoinPoint joinPoint) {
//        MethodSignature sign = (MethodSignature) joinPoint.getSignature();
//        Method method = sign.getMethod();
//        if (VOID.equals(method.getReturnType().toString())) {
//            throw new RuntimeException("m-custom Method return type cannot be void");
//        }
//
//        DelRedisCache annotation = method.getAnnotation(DelRedisCache.class);
//        String[] keys = annotation.key();
//        if (CommonUtil.isEmpty(keys)) {
//            throw new RuntimeException("m-custom Reids key can not be empty");
//        }
//        for (String key : keys) {
//            key = (A_S_REDIS_CACHE + key);
//            redisUtil.delLike(key);
//        }
//    }
//
//    @Around("annotationPointCut()")
//    public Object advice(ProceedingJoinPoint joinPoint) throws Throwable {
//        return joinPoint.proceed();
//    }
//
//    @After("annotationPointCut()")
//    public void after() {
//    }
//}
